package com.woniuxy.ticketuser.configuration;

import com.woniuxy.ticketuser.realm.UserRealm;
import org.apache.shiro.mgt.SecurityManager;
import org.apache.shiro.spring.web.ShiroFilterFactoryBean;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @ClassName ShiroConfig
 * @Description TODO
 * @Author zx
 * @Date 2021-03-01 21:39:47
 * @Version 1.0
 */
@Configuration
public class ShiroConfig {
    //配置realm
    @Bean
    public UserRealm realm(){
        return new UserRealm();
    }

    //安全管理器
    @Bean
    public SecurityManager securityManager(UserRealm realm){
        DefaultWebSecurityManager manager = new DefaultWebSecurityManager();
        //设置realm
        manager.setRealm(realm);
        return manager;
    }

    //shiro过滤器
//    public ShiroFilterFactoryBean shiroFilterFactoryBean(SecurityManager securityManager){
//        ShiroFilterFactoryBean factoryBean = new ShiroFilterFactoryBean();
//        //配置安全管理器
//        factoryBean.setSecurityManager(securityManager);
//        //配置没有权限时要请求的url（页面、后台url）
//        factoryBean.setUnauthorizedUrl("");
//    }
}
